package com.example.skymallseckillproductapi.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.situ.shop.model.SecKillProduct;
import com.situ.shop.model.DTO.SecKillProductWithProductInfo;
import com.situ.shop.model.search.SecKillProductSearchBean;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;

@Mapper
public interface SecKillProductMapper extends BaseMapper<SecKillProduct> {
    default Page<SecKillProduct>  findAll(Page<SecKillProduct> page,
                                          SecKillProductSearchBean spsb){
        LambdaQueryWrapper<SecKillProduct> qw = Wrappers.lambdaQuery(spsb);
        return selectPage(page, qw);
    }

    // 查询单个秒杀商品及其关联商品信息
    SecKillProductWithProductInfo selectByIdWithProductInfo(@Param("id") Integer id);

    // 查询所有秒杀商品及其关联商品信息
    List<SecKillProductWithProductInfo> selectAllWithProductInfo();

    // 根据条件查询秒杀商品及其关联商品信息
    List<SecKillProductWithProductInfo> selectWithProductInfoByCondition(SecKillProductSearchBean condition);
}
